<template>
  <!-- 分类关联商品 -->
  <div class="ref-goods">
    <div class="head" v-for="item in list" :key="item.id">
      <h3>- {{item.name}} -</h3>
      <p class="tag">温暖柔软，品质之选</p>
      <XtxMore />
      <div class="body">
        <GoodsItem v-for="i in item.goods" :key="i.id" :i="i" />
      </div>
    </div>
    <!-- {{list}} -->
  </div>
</template>

<script>
import XtxMore from "@/components/index/xtx-more.vue"
import GoodsItem from '@/components/categroy/GoodsItem.vue'
import { getCategory } from '@/utils/api/homeapi'
export default {
  components: { XtxMore, GoodsItem },
  props: ['nowid'],
  data() {
    return {
      list: null,
    }
  },
  methods: {
    async getlist() {
      // console.log(id);
      let res = await getCategory(this.nowid)
      //   console.log(res);
      this.list = res.result.children
      //   console.log(this.list);
    }
  },
  mounted() {
    // this.getlist(this.nowid)
  },
  watch: {
    nowid(val) {
      if (val) {
        this.getlist()
      }
    }
  },
}
</script>

<style lang="scss" scoped>
h3 {
  font-size: 28px;
  color: #666;
  font-weight: normal;
  text-align: center;
  line-height: 100px;
}
.ref-goods {
  background-color: #fff;
  margin-top: 20px;
  position: relative;
  .head {
    .xtx-more {
      position: absolute;
      top: 20px;
      right: 20px;
    }
    .tag {
      text-align: center;
      color: #999;
      font-size: 20px;
      position: relative;
      top: -20px;
    }
  }
  .body {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    padding: 0 65px 30px;
  }
}
</style>